package com.cheesmo.nzb.client;

public class DownloadThread extends Thread
{
	String group;
	String messageId;
	String downloadFileName;
	ConnectionPool pool;
	boolean result = false;

	public DownloadThread(ConnectionPool pool, String group, String messageId, String downloadFilename) {
		this.group = group;
		this.messageId = messageId;
		this.downloadFileName = downloadFilename;
		this.pool = pool;
	}

	public void run()
	{
		NNTPConnection connection = null;
		try {
			connection = this.pool.getConnection();
			this.result = connection.downloadSegment(this.group, this.messageId, this.downloadFileName);
		} finally {
			if (connection != null)
				this.pool.releaseConnection(connection);
		}
	}

	public boolean getResult() {
		return this.result;
	}
}